<?php

/**
 * Manage data of "Email Template" table 
 *
 * @author tham
 * Date : 17/1/2013
 */
class Emailtemplate {
    /* Get list email form database 
     * @param none
     * @return $listemail
     */

    const TABLENAME = "travel_email_templates";

    public static function ListEmailTemplate() {
        global $wpdb;
        $listemail = $wpdb->get_results('SELECT * FROM ' . self::TABLENAME);
        return $listemail;
    }

    public static function ListEmailTempByIdEmailTemp($id_email_temp) {

        global $wpdb;

        $listemail = $wpdb->get_results('SELECT * FROM `'.self::TABLENAME.'` where id_email_temp=' . $id_email_temp);

        return $listemail;
    }

    /* Update Template Email
     * @param $datasend
     * @return none
     * author:tham
     */

    public static function UpdateTemplateIDEmail($datasend) {

        global $wpdb;
        $sql = "UPDATE ".self::TABLENAME."
			               SET  title= '" . $datasend['title'] . "',
						        description ='" . $datasend['description'] . "',
								subject ='" . $datasend['subject'] . "',
								content ='" . $datasend['content'] . "'
							Where id_email_temp = " . $datasend['id_email_temp'];
        $wpdb->query($sql);
    }

}
